# 启动服务器的
from tornado.httpserver import HTTPServer
# 这个是启动
from tornado.ioloop import IOLoop
# 控制路由分发的
from tornado.web import Application
# 设置请求的
from tornado.web import RequestHandler
# 调用父类，里面写get，post请求
class IndexHandler(RequestHandler):
    def get(self):
        # 用write写入
        self.write('hello')
# 配置url，路由分发
class CustomApplication(Application):
    def __init__(self):
        # 路由分发
        urls = [
            ('/', IndexHandler)
        ]
        # 调用父类方法，放入urls
        super(CustomApplication,self).__init__(urls)


def create_server():
    server = HTTPServer(CustomApplication())
    # 监听8800端口
    server.listen(8800)
    print('127.0.0.1:8800')
    # 启动服务器
    IOLoop.current().start()
if __name__ == '__main__':
    # 启动
    create_server()